package com.shuwa.controller;

import com.shuwa.pojo.OrderInf;
import com.shuwa.pojo.OrderList;
import com.shuwa.pojo.ProductorLabel;
import com.shuwa.service.ProductorService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/product")
public class ProductorController {

    @Resource
    ProductorService productorService;

    @RequestMapping(value = "/productinfo",produces = "application/json; charset=utf-8",method= RequestMethod.POST)
    public List<ProductorLabel> show(@RequestParam(value="label") String label){
        /*返回商品列表*/
        List<ProductorLabel>labellist=productorService.ShowLabelProduct(label);
        return labellist;
    }

    @RequestMapping(value = "myreleased")
    public List<OrderList> showMyReleasedList(HttpServletRequest httpServletRequest){
        Integer userpid=(Integer) httpServletRequest.getSession().getAttribute("userid");
        List<OrderList> myreleased=productorService.GetMyReleasedOrderList(userpid);
        return myreleased;
    }
    @RequestMapping(value = "myorder")
    public List<OrderList> showMyOrderList(HttpServletRequest httpServletRequest){
        Integer userpid=(Integer) httpServletRequest.getSession().getAttribute("userid");
        List<OrderList> myorder=productorService.GetMyOrderList(userpid);
        return myorder;

    }
    @RequestMapping(value = "orderInf")
    public OrderInf getOrderInf(@RequestParam(value="pid") Integer pid){
    return  productorService.GetOrderInf(pid);
    }

}
